using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Viettel.VOFFICE.DAO.Models.Mapping
{
    public class SubmissionMap : EntityTypeConfiguration<Submission>
    {
        public SubmissionMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Contents)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.Request)
                .HasMaxLength(500);

            this.Property(t => t.OtherIdea)
                .HasMaxLength(500);

            // Table & Column Mappings
            this.ToTable("Submission");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Contents).HasColumnName("Contents");
            this.Property(t => t.Request).HasColumnName("Request");
            this.Property(t => t.OtherIdea).HasColumnName("OtherIdea");
            this.Property(t => t.DocProgressId).HasColumnName("DocProgressId");
            this.Property(t => t.CreatedAt).HasColumnName("CreatedAt");
            this.Property(t => t.UpdatedAt).HasColumnName("UpdatedAt");
            this.Property(t => t.SubmissionStatus).HasColumnName("SubmissionStatus");
            this.Property(t => t.CreatorId).HasColumnName("CreatorId");

            // Relationships
            this.HasRequired(t => t.DocumentProgress)
                .WithMany(t => t.Submissions)
                .HasForeignKey(d => d.DocProgressId);

        }
    }
}
